package com.central.apps.controller;

import com.central.app.service.HandlerService;
import com.central.common.web.Result;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@Api(tags = "润滑工单应用接口")
@RequestMapping("/lubricanttask")
public class LubricanttaskAppController {

    @Autowired private HandlerService handlerService;

    @PostMapping("/updSonInfos")
    public Result updSonInfos(@RequestParam String rhbznum,@RequestParam String lubtasknum) throws Exception{
        //根据主表润滑标准编号rhbznum 获取润滑标准子表信息
        String getSonSql ="select * from bl_lubricantstandardline where lubstdnum ='"+rhbznum+"';";
        List<Map<String, Object>> bySql = handlerService.findBySql(getSonSql);
//        Map<String, Object> map =new HashMap<>();
//        map.put("lubstdnum",rhbznum);
//        List<Map<String, Object>> bySql = handlerService.findList("bl_lubricantstandardline",map);
        return Result.succeed(bySql,"查询润滑标准成功");
//        Map<String, Object> map =new HashMap<>();
//        int total =0;
//        for( int i=0;i<bySql.size();i++){
//            String inspectionassetnum = (String) bySql.get(0).get("inspectionassetnum");
//            String inspectionassetname = (String) bySql.get(0).get("inspectionassetname");
//            String lubricantpart = (String) bySql.get(0).get("lubricantpart");
//            String lubricantmethod = (String) bySql.get(0).get("lubricantmethod");
//            String lubricantpoint = (String) bySql.get(0).get("lubricantpoint");
//            String lubricantstandrad = (String) bySql.get(0).get("lubricantstandrad");
//            String greasegrade = (String) bySql.get(0).get("greasegrade");
//        //更新到润滑工单子表
//        String updSql ="insert into bl_lubricanttaskline (inspectionassetnum,inspectionassetname,lubricantpart,lubricantmethod,lubricantpoint,lubricantstandrad,greasegrade,lubtasknum) values('"
//                +inspectionassetnum+"','"
//                +inspectionassetname+"','"
//                +lubricantpart+"','"
//                +lubricantmethod+"','"
//                +lubricantpoint+"','"
//                +lubricantstandrad+"','"
//                +lubricantstandrad+"','"
//                +lubtasknum+"');";
//        handlerService.updateBySql(updSql);
//        total =i+1;
//        }
//        return Result.succeed(total,"更新数量:"+Integer.toString(total));
    }
}
